<template>
  <div class="box">
    <el-breadcrumb separator=">">
      <el-breadcrumb-item to="/login" replace>首页</el-breadcrumb-item>
      <el-breadcrumb-item>平台运营</el-breadcrumb-item>
      <el-breadcrumb-item to="/login/operation/indexBanner" replace>首页广告图</el-breadcrumb-item>
      <el-breadcrumb-item>广告图组详情</el-breadcrumb-item>
    </el-breadcrumb>
    <div class="tableBox">
      <div class="tableTitle">广告图组详情</div>
      <div class="searchBox">
        <el-form size="mini" inline>
          <div class="block">
            <el-form-item>
              <el-button type="primary" icon="el-icon-circle-plus" @click="addMap">添加</el-button>
            </el-form-item>
          </div>
        </el-form>
      </div>
      <el-row>
        <el-col :span="6">图组编号</el-col>
        <el-col :span="6">5</el-col>
        <el-col :span="6">板块名称</el-col>
        <el-col :span="6">全城美食</el-col>
      </el-row>
      <el-table :data="tableData">
        <el-table-column prop="" label="标题" align="center"></el-table-column>
        <el-table-column prop="" label="图片" align="center"></el-table-column>
        <el-table-column prop="" label="跳转类型" align="center"></el-table-column>
        <el-table-column prop="" label="外链地址" align="center"></el-table-column>
        <el-table-column prop="" label="板块编号" align="center"></el-table-column>
        <el-table-column prop="" label="店铺名称" align="center"></el-table-column>
        <el-table-column prop="" label="商户编号" align="center"></el-table-column>
        <el-table-column prop="" label="编辑" align="center"></el-table-column>
      </el-table>
      <div class="addMap" v-if="addMapShow">
        <div class="content">
          <div class="upload clearFix">
            <el-upload class="upload-demo" :show-file-list="false" drag
                       action="https://jsonplaceholder.typicode.com/posts/"
                       :on-success="handleSuccess" :before-upload="beforeAvatarUpload">
              <i class="el-icon-upload"></i>
              <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
            </el-upload>
            <div class="img">
              <img :src="option.imageUrl" alt="">
            </div>
          </div>
          <el-form :model="option[0]" size="mini" label-width="160px">
            <el-form-item label="组编号">
              <el-input v-model="option[0].imageUrl" readonly></el-input>
              <span>组编号</span>
            </el-form-item>
            <el-form-item label="图片上传返回地址">
              <el-input v-model="option[0].imageUrl"></el-input>
              <span>用于图片的展示</span>
            </el-form-item>
            <el-form-item label="图片外部链接地址">
              <el-input v-model="option[0].imageUrl"></el-input>
              <span>跳转其他页面url</span>
            </el-form-item>
            <el-form-item label="图片编号">
              <el-input v-model="option[0].imageUrl" readonly></el-input>
              <span>图片编号</span>
            </el-form-item>
            <el-form-item label="跳转类型">
              <el-select v-model="option[0].linkType" placeholder="请选择">
                <el-option v-for="item in typeOptions" :key="item.value" :label="item.label"
                           :value="item.value"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="地区">
              <el-select v-model="option[0].linkType" placeholder="请选择">
                <el-option v-for="item in shopTypeOptions" :key="item.value" :label="item.label"
                           :value="item.value"></el-option>
              </el-select>
            </el-form-item>
          </el-form>
        </div>
        <div class="content">
          <div class="upload clearFix">
            <el-upload class="upload-demo" :show-file-list="false" drag
                       action="https://jsonplaceholder.typicode.com/posts/"
                       :on-success="handleSuccess" :before-upload="beforeAvatarUpload">
              <i class="el-icon-upload"></i>
              <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
            </el-upload>
            <div class="img">
              <img :src="option.imageUrl" alt="">
            </div>
          </div>
          <el-form :model="option[1]" size="mini" label-width="160px">
            <el-form-item label="组编号">
              <el-input v-model="option[1].imageUrl" readonly></el-input>
              <span>组编号</span>
            </el-form-item>
            <el-form-item label="图片上传返回地址">
              <el-input v-model="option[1].imageUrl"></el-input>
              <span>用于图片的展示</span>
            </el-form-item>
            <el-form-item label="图片外部链接地址">
              <el-input v-model="option[1].imageUrl"></el-input>
              <span>跳转其他页面url</span>
            </el-form-item>
            <el-form-item label="图片编号">
              <el-input v-model="option[1].imageUrl" readonly></el-input>
              <span>图片编号</span>
            </el-form-item>
            <el-form-item label="跳转类型">
              <el-select v-model="option[1].linkType" placeholder="请选择">
                <el-option v-for="item in typeOptions" :key="item.value" :label="item.label"
                           :value="item.value"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="地区">
              <el-select v-model="option[1].linkType" placeholder="请选择">
                <el-option v-for="item in shopTypeOptions" :key="item.value" :label="item.label"
                           :value="item.value"></el-option>
              </el-select>
            </el-form-item>
          </el-form>
        </div>
        <div class="content">
          <div class="upload clearFix">
            <el-upload class="upload-demo" :show-file-list="false" drag
                       action="https://jsonplaceholder.typicode.com/posts/"
                       :on-success="handleSuccess" :before-upload="beforeAvatarUpload">
              <i class="el-icon-upload"></i>
              <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
            </el-upload>
            <div class="img">
              <img :src="option.imageUrl" alt="">
            </div>
          </div>
          <el-form :model="option[2]" size="mini" label-width="160px">
            <el-form-item label="组编号">
              <el-input v-model="option[2].imageUrl" readonly></el-input>
              <span>组编号</span>
            </el-form-item>
            <el-form-item label="图片上传返回地址">
              <el-input v-model="option[2].imageUrl"></el-input>
              <span>用于图片的展示</span>
            </el-form-item>
            <el-form-item label="图片外部链接地址">
              <el-input v-model="option[2].imageUrl"></el-input>
              <span>跳转其他页面url</span>
            </el-form-item>
            <el-form-item label="图片编号">
              <el-input v-model="option[2].imageUrl" readonly></el-input>
              <span>图片编号</span>
            </el-form-item>
            <el-form-item label="跳转类型">
              <el-select v-model="option[2].linkType" placeholder="请选择">
                <el-option v-for="item in typeOptions" :key="item.value" :label="item.label"
                           :value="item.value"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="地区">
              <el-select v-model="option[2].linkType" placeholder="请选择">
                <el-option v-for="item in shopTypeOptions" :key="item.value" :label="item.label"
                           :value="item.value"></el-option>
              </el-select>
            </el-form-item>
          </el-form>
        </div>
        <div class="content">
          <div class="upload clearFix">
            <el-upload class="upload-demo" :show-file-list="false" drag
                       action="https://jsonplaceholder.typicode.com/posts/"
                       :on-success="handleSuccess" :before-upload="beforeAvatarUpload">
              <i class="el-icon-upload"></i>
              <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
            </el-upload>
            <div class="img">
              <img :src="option.imageUrl" alt="">
            </div>
          </div>
          <el-form :model="option[3]" size="mini" label-width="160px">
            <el-form-item label="组编号">
              <el-input v-model="option[3].imageUrl" readonly></el-input>
              <span>组编号</span>
            </el-form-item>
            <el-form-item label="图片上传返回地址">
              <el-input v-model="option[3].imageUrl"></el-input>
              <span>用于图片的展示</span>
            </el-form-item>
            <el-form-item label="图片外部链接地址">
              <el-input v-model="option[3].imageUrl"></el-input>
              <span>跳转其他页面url</span>
            </el-form-item>
            <el-form-item label="图片编号">
              <el-input v-model="option[3].imageUrl" readonly></el-input>
              <span>图片编号</span>
            </el-form-item>
            <el-form-item label="跳转类型">
              <el-select v-model="option[3].linkType" placeholder="请选择">
                <el-option v-for="item in typeOptions" :key="item.value" :label="item.label"
                           :value="item.value"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="地区">
              <el-select v-model="option[3].linkType" placeholder="请选择">
                <el-option v-for="item in shopTypeOptions" :key="item.value" :label="item.label"
                           :value="item.value"></el-option>
              </el-select>
            </el-form-item>
          </el-form>
        </div>
        <div class="content">
          <div class="upload clearFix">
            <el-upload class="upload-demo" :show-file-list="false" drag
                       action="https://jsonplaceholder.typicode.com/posts/"
                       :on-success="handleSuccess" :before-upload="beforeAvatarUpload">
              <i class="el-icon-upload"></i>
              <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
            </el-upload>
            <div class="img">
              <img :src="option.imageUrl" alt="">
            </div>
          </div>
          <el-form :model="option[4]" size="mini" label-width="160px">
            <el-form-item label="组编号">
              <el-input v-model="option[4].imageUrl" readonly></el-input>
              <span>组编号</span>
            </el-form-item>
            <el-form-item label="图片上传返回地址">
              <el-input v-model="option[4].imageUrl"></el-input>
              <span>用于图片的展示</span>
            </el-form-item>
            <el-form-item label="图片外部链接地址">
              <el-input v-model="option[4].imageUrl"></el-input>
              <span>跳转其他页面url</span>
            </el-form-item>
            <el-form-item label="图片编号">
              <el-input v-model="option[4].imageUrl" readonly></el-input>
              <span>图片编号</span>
            </el-form-item>
            <el-form-item label="跳转类型">
              <el-select v-model="option[4].linkType" placeholder="请选择">
                <el-option v-for="item in typeOptions" :key="item.value" :label="item.label"
                           :value="item.value"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="地区">
              <el-select v-model="option[4].linkType" placeholder="请选择">
                <el-option v-for="item in shopTypeOptions" :key="item.value" :label="item.label"
                           :value="item.value"></el-option>
              </el-select>
            </el-form-item>
          </el-form>
        </div>
        <div class="content">
          <div class="upload clearFix">
            <el-upload class="upload-demo" :show-file-list="false" drag
                       action="https://jsonplaceholder.typicode.com/posts/"
                       :on-success="handleSuccess" :before-upload="beforeAvatarUpload">
              <i class="el-icon-upload"></i>
              <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
            </el-upload>
            <div class="img">
              <img :src="option.imageUrl" alt="">
            </div>
          </div>
          <el-form :model="option[5]" size="mini" label-width="160px">
            <el-form-item label="组编号">
              <el-input v-model="option[5].imageUrl" readonly></el-input>
              <span>组编号</span>
            </el-form-item>
            <el-form-item label="图片上传返回地址">
              <el-input v-model="option[5].imageUrl"></el-input>
              <span>用于图片的展示</span>
            </el-form-item>
            <el-form-item label="图片外部链接地址">
              <el-input v-model="option[5].imageUrl"></el-input>
              <span>跳转其他页面url</span>
            </el-form-item>
            <el-form-item label="图片编号">
              <el-input v-model="option[5].imageUrl" readonly></el-input>
              <span>图片编号</span>
            </el-form-item>
            <el-form-item label="跳转类型">
              <el-select v-model="option[5].linkType" placeholder="请选择">
                <el-option v-for="item in typeOptions" :key="item.value" :label="item.label"
                           :value="item.value"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="地区">
              <el-select v-model="option[5].linkType" placeholder="请选择">
                <el-option v-for="item in shopTypeOptions" :key="item.value" :label="item.label"
                           :value="item.value"></el-option>
              </el-select>
            </el-form-item>
          </el-form>
        </div>
        <div class="content">
          <div class="upload clearFix">
            <el-upload class="upload-demo" :show-file-list="false" drag
                       action="https://jsonplaceholder.typicode.com/posts/"
                       :on-success="handleSuccess" :before-upload="beforeAvatarUpload">
              <i class="el-icon-upload"></i>
              <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
            </el-upload>
            <div class="img">
              <img :src="option.imageUrl" alt="">
            </div>
          </div>
          <el-form :model="option[6]" size="mini" label-width="160px">
            <el-form-item label="组编号">
              <el-input v-model="option[6].imageUrl" readonly></el-input>
              <span>组编号</span>
            </el-form-item>
            <el-form-item label="图片上传返回地址">
              <el-input v-model="option[6].imageUrl"></el-input>
              <span>用于图片的展示</span>
            </el-form-item>
            <el-form-item label="图片外部链接地址">
              <el-input v-model="option[6].imageUrl"></el-input>
              <span>跳转其他页面url</span>
            </el-form-item>
            <el-form-item label="图片编号">
              <el-input v-model="option[6].imageUrl" readonly></el-input>
              <span>图片编号</span>
            </el-form-item>
            <el-form-item label="跳转类型">
              <el-select v-model="option[6].linkType" placeholder="请选择">
                <el-option v-for="item in typeOptions" :key="item.value" :label="item.label"
                           :value="item.value"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="地区">
              <el-select v-model="option[6].linkType" placeholder="请选择">
                <el-option v-for="item in shopTypeOptions" :key="item.value" :label="item.label"
                           :value="item.value"></el-option>
              </el-select>
            </el-form-item>
          </el-form>
        </div>
      </div>
    </div>
  </div>
</template>

<script type="text/ecmascript-6">
  export default {
    name: 'bannerGroupInfo',
    data () {
      return {
        tableData: [],
        option: [
          {
            imageUrl: ''
          },
          {
            imageUrl: ''
          },
          {
            imageUrl: ''
          },
          {
            imageUrl: ''
          },
          {
            imageUrl: ''
          },
          {
            imageUrl: ''
          },
          {
            imageUrl: ''
          }
        ],
        shopTypeOptions: [],
        typeOptions: [],
        addMapShow: false
      }
    },
    created () {
    },
    methods: {
      handleSuccess (res, file) {
        this.option.imageUrl = URL.createObjectURL(file.raw)
      },
      beforeAvatarUpload (file) {
        const isJPG = file.type === 'image/jpeg'
        const isLt2M = file.size / 1024 / 1024 < 2

        if (!isJPG) {
          this.$message.error('上传头像图片只能是 JPG 格式!')
        }
        if (!isLt2M) {
          this.$message.error('上传头像图片大小不能超过 2MB!')
        }
        return isJPG && isLt2M
      },
      addMap () {
        this.addMapShow = !this.addMapShow
      }
    },
    components: {}
  }
</script>

<style lang="less" ref="stylesheet/less" scoped>
  .el-row {
    display: flex;
    text-align: center;

    .el-col {
      padding: 15px 0;
      border-bottom: 1px solid #eee;
      border-right: 1px solid #eee;

      &:last-child {
        border-right: none;
      }
    }
  }
  .addMap {
    padding: 20px;

    .upload {
      text-align: center;

      .upload-demo {
        float: left;
        width: 50%;
      }

      .img {
        float: right;
        width: 50%;

        img {
          width: 358px;
          height: 178px;
          border: 1px dashed #d9d9d9;
        }
      }
    }

    .el-form {
      margin: 20px auto 0;
      width: 60%;

      .el-input {
        width: 70%;
      }
    }
  }
</style>
